package com.log.fun;

import java.util.List;
import java.util.Map;

/**
 * @ClassName FunChain
 * @Author xiezhuocai
 * @Description 方法链
 * @Date 2022/5/14 17:25
 */
public abstract class FunChain {


    public FunChain(String name){
        this.name = name;
    }

    private String name;

    private FunChain chains;

    public FunChain getFunChain() {
        return chains;
    }

    public void setFunChain(FunChain chains) {
        this.chains = chains;
    }

    public void handlerRequest(Map<String,String> keys, Map<String,String> value) {
        if(keys.isEmpty()){
            return;
        } else {
            keys.forEach((k,v) -> {
                if(v.equals(name)){
                    value.put(k,fun());
                }
            });
            if(chains!=null){
                chains.handlerRequest(keys,value);
            }
        }
    }

    protected abstract String fun();

}
